#include<iostream>
using namespace std;
const int N = 55;
int arr[N];
int n;
int main()
{
	cin >> n;
	bool flag = 1;
	int maidx = n, ma = 0;
	int miidx = 0, mi = 1e9;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		if (arr[i - 1] > arr[i]) {
			flag = 0;
		}
		if (ma < arr[i]) {
			ma = arr[i];
			maidx = i;
		}
		if (mi > arr[i]) {
			mi = arr[i];
			miidx = i;
		}
	}
	if (flag) {
		cout << 0 << endl;
		return 0;
	}
	cout << mi << " " << ma << endl;
	cout << miidx << " " << maidx << endl;
	if (miidx == 1 || maidx == n) {
		cout << 1 << endl;
	}
	else if (maidx == 1 && miidx == n) {
		cout << 3 << endl;
	}
	else {
		cout << 2 << endl;
	}
	return 0;
}